package com.bluevally.microservice.user.main;

import com.bluevally.framework.client.channel.ChannelFactory;
import com.bluevally.framework.client.context.AppContext;
import com.bluevally.microservice.user.bindable.UserServiceImpl;
import com.bluevally.microservice.user.dao.JdbcHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.sql.DataSource;
import java.io.IOException;

/**
 * Created by lixiaoming on 2019/1/9.
 */
public class User {
    private static Log logger = LogFactory.getLog(UserServiceImpl.class);

    public static void main(String[] args) throws IOException, InterruptedException {
        logger.info("user start...");
        DataSource ds = JdbcHelper.create();
        AppContext.addBean("dataSource",ds);
        UserServiceImpl userService = AppContext.proxyBindService(UserServiceImpl.class);
        ChannelFactory factory = ChannelFactory.getInstance();
        factory.init("user.properties");
        factory.startServer(userService);
        logger.info("done");
    }
}
